import request from '@/utils/request'

// 查询存储教师预约记录列表
export function listReservation(query) {
  return request({
    url: '/infomanagement/reservation/list',
    method: 'get',
    params: query
  })
}

// 查询存储教师预约记录详细
export function getReservation(id) {
  return request({
    url: '/infomanagement/reservation/' + id,
    method: 'get'
  })
}

// 新增存储教师预约记录
export function addReservation(data) {
  return request({
    url: '/infomanagement/reservation', 
    method: 'post',
    data: data
  })
}

// 修改存储教师预约记录
export function updateReservation(data) {
  return request({
    url: '/infomanagement/reservation',
    method: 'put',
    data: data
  })
}

// 删除存储教师预约记录
export function delReservation(id) {
  return request({
    url: '/infomanagement/reservation/' + id,
    method: 'delete'
  })
}

//根据工号和dateId查询预约记录
export function queryByTeacherIdAndDateId(data) {
  return request({
    url: '/infomanagement/reservation/queryByTeacherIdAndDateId',
    method: 'get',
    params: data
  })
}

export function queryReservationsByEmployeeIdAndStatus({ employeeId, status }) {

  return request({
    url: '/infomanagement/reservation/queryByTeacherIdAndStatus',
    method: 'get',
    params: {
      teacherCode: employeeId,
      reservationStatus: parseInt(status)
    },
    noGlobalLoading: true // 禁用全局加载动画，避免干扰调试
  }).then(response => {
    console.log('request响应数据:', response)
    return response
  }).catch(error => {
    console.error('request请求失败:', error)
    throw error
  })
}
